/*
 * generate by table-builder.Don't modify it
 */
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using System.Collections.Generic;


namespace CfgTable
{
    public partial class TbCfgItem
    {
        private readonly Dictionary<int, CfgItem> _dataMap;
        private readonly List<CfgItem> _dataList;


        public TbCfgItem(ByteBuf _buf)
        {
            //first read common data
            _TbCommonItem _commonData = null;
            var commonSize = _buf.ReadSize();
            if (commonSize > 0)
            {
                _commonData = new _TbCommonItem(_buf);
            }

            //then read row data
            var size = _buf.ReadSize();
            _dataMap = new Dictionary<int, CfgItem>(size * 3 / 2);
            _dataList = new List<CfgItem>(size);

            for (int i = 0; i < size; i++)
            {
                CfgItem _v;
                _v = CfgItem.DeserializeCfgItem(_buf, _commonData);
                _dataList.Add(_v);
                _dataMap.Add(_v.Id, _v);
            }

            // read extra fields 

            PostInit();
        }

        public IReadOnlyDictionary<int, CfgItem> DataMap => _dataMap;
        public IReadOnlyList<CfgItem> DataList => _dataList;

        public CfgItem Get(int key)
        {
            if (_dataMap.TryGetValue(key, out var v))
            {
                return v;
            }
            IQIGame.Onigao.Framework.LogGame.LogError("[TbCfgItem] config not found,id:" + key.ToString());

            return null;
        }

        public CfgItem GetWithoutError(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;

        /// <summary>
        /// table data file
        /// </summary>
        public static string TableFileName { get; } = "item";

        /// <summary>
        /// load table function
        /// </summary>
        public static TbCfgItem LoadFromFunc(System.Func<string, ByteBuf> loadFunc)
        {
            return new TbCfgItem(loadFunc(TableFileName));
        }

        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();

    }

    public partial class CfgItem
    {
        private CfgItem(ByteBuf _buf, _TbCommonItem _commonData)
        {
            Id = _buf.ReadInt();
            Name = TableCenter.GetI18NText(_buf.ReadInt());
            Describe = TableCenter.GetI18NText(_buf.ReadInt());
            Type = (ItemType)(_buf.ReadInt());
            TypeDesc = TableCenter.GetI18NText(_buf.ReadInt());
            SubType = _buf.ReadInt();
            Quality = _buf.ReadInt();
            Tab = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; Tags = _commonData._field0[dataIndex]; }
            Sort = _buf.ReadInt();
            DropMaxNum = _buf.ReadInt();
            SellID = _buf.ReadInt();
            SellPrice = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; Icon = _commonData._field1[dataIndex]; }
            EffectTxt = TableCenter.GetI18NText(_buf.ReadInt());
            IsBagShow = _buf.ReadBool();
            IsPanelShow = _buf.ReadBool();
            MaxNum = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; MoneyIcon = _commonData._field2[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; StartTime = _commonData._field3[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; ExpirationTime = _commonData._field4[dataIndex]; }
            BatchUseLimit = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; UseArea = _commonData._field5[dataIndex]; }
            Durability = _buf.ReadInt();
            RetentionAfterUse = _buf.ReadBool();
            UseConditionID = _buf.ReadInt();
            ItemEffectID = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; WearableHeroClass = _commonData._field6[dataIndex]; }
            InitialLevel = _buf.ReadInt();
            InitialStar = _buf.ReadInt();
            StarLimit = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; PabilityID = _commonData._field7[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; Card = _commonData._field8[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; DecomposeReward = _commonData._field9[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; AddService = _commonData._field10[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; RemoveService = _commonData._field11[dataIndex]; }

            PostInit();
        }

        internal static CfgItem DeserializeCfgItem(ByteBuf _buf, _TbCommonItem _commonData)
        {
            return new CfgItem(_buf, _commonData);
        }

        /// <summary>
        /// major key
        /// </summary>
        public int Id { get; private set; }

        /// <summary>
        /// 名称文本
        /// </summary>
        public string Name { get; private set; }
        /// <summary>
        /// 物品描述
        /// </summary>
        public string Describe { get; private set; }
        /// <summary>
        /// 类型
        /// </summary>
        public ItemType Type { get; private set; }
        /// <summary>
        /// 显示类型描述
        /// </summary>
        public string TypeDesc { get; private set; }
        /// <summary>
        /// 子类型
        /// </summary>
        public int SubType { get; private set; }
        /// <summary>
        /// 品质
        /// </summary>
        public int Quality { get; private set; }
        /// <summary>
        /// 背包界面页签（0 不显示 1礼包 2非英雄碎片素材 3英雄碎片 4迷宫道具 5其他）
        /// </summary>
        public int Tab { get; private set; }
        /// <summary>
        /// 标签类型（目前红点在使用）
        /// </summary>
        public IReadOnlyList<int> Tags { get; private set; }
        /// <summary>
        /// 显示排序
        /// </summary>
        public int Sort { get; private set; }
        /// <summary>
        /// 全局最大掉落数量
        /// </summary>
        public int DropMaxNum { get; private set; }
        /// <summary>
        /// 卖出资源ID
        /// </summary>
        public int SellID { get; private set; }
        /// <summary>
        /// 卖出价格
        /// </summary>
        public int SellPrice { get; private set; }
        /// <summary>
        /// 图标
        /// </summary>
        public string Icon { get; private set; }
        /// <summary>
        /// 道具使用效果描述
        /// </summary>
        public string EffectTxt { get; private set; }
        /// <summary>
        /// 是否背包显示（0不显示，1显示）
        /// </summary>
        public bool IsBagShow { get; private set; }
        /// <summary>
        /// 是否界面展示（0不显示，1显示）
        /// </summary>
        public bool IsPanelShow { get; private set; }
        /// <summary>
        /// 拥有数量上限
        /// </summary>
        public int MaxNum { get; private set; }
        /// <summary>
        /// 资产条图标
        /// </summary>
        public string MoneyIcon { get; private set; }
        /// <summary>
        /// 生效开始期
        /// </summary>
        public string StartTime { get; private set; }
        /// <summary>
        /// 生效结束期
        /// </summary>
        public string ExpirationTime { get; private set; }
        /// <summary>
        /// 批量使用限制
        /// </summary>
        public int BatchUseLimit { get; private set; }
        /// <summary>
        /// 道具使用的区域
        /// </summary>
        public IReadOnlyList<int> UseArea { get; private set; }
        /// <summary>
        /// 耐久度
        /// </summary>
        public int Durability { get; private set; }
        /// <summary>
        /// 使用后是否保留-不扣除
        /// </summary>
        public bool RetentionAfterUse { get; private set; }
        /// <summary>
        /// 使用条件
        /// </summary>
        public int UseConditionID { get; private set; }
        /// <summary>
        /// 道具效果ID
        /// </summary>
        public int ItemEffectID { get; private set; }
        /// <summary>
        /// 该装备可被穿戴的英雄对应的定位类型（1.坦克、2.输出、3.治疗）
        /// </summary>
        public IReadOnlyList<int> WearableHeroClass { get; private set; }
        /// <summary>
        /// 初始等级（外部默认1）
        /// </summary>
        public int InitialLevel { get; private set; }
        /// <summary>
        /// 星级
        /// </summary>
        public int InitialStar { get; private set; }
        /// <summary>
        /// 升星上限
        /// </summary>
        public int StarLimit { get; private set; }
        /// <summary>
        /// 属性被动槽1
        /// </summary>
        public IReadOnlyList<IReadOnlyList<int>> PabilityID { get; private set; }
        /// <summary>
        /// 卡面图片
        /// </summary>
        public string Card { get; private set; }
        /// <summary>
        /// 分解返还材料
        /// </summary>
        public IReadOnlyList<int> DecomposeReward { get; private set; }
        /// <summary>
        /// 装备效果
        /// </summary>
        public IReadOnlyList<int> AddService { get; private set; }
        /// <summary>
        /// 取下效果
        /// </summary>
        public IReadOnlyList<int> RemoveService { get; private set; }

        /// <summary>
        /// Icon资源全路径
        /// </summary>
        public string Icon_fullPath => $"Res/05_Images/Sprite/{Icon}";
        /// <summary>
        /// MoneyIcon 资源全路径
        /// </summary>
        public string MoneyIcon_fullPath => $"Res/05_Images/Sprite/{MoneyIcon}";
        /// <summary>
        /// Card资源全路径
        /// </summary>
        public string Card_fullPath => $"Res/05_Images/Texture/{Card}";

        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();
    }

    /// <summary>
    /// internal common data.Optimize memory
    /// </summary>
    internal class _TbCommonItem
    {

        internal IReadOnlyList<IReadOnlyList<int>> _field0 { get; private set; }
        internal IReadOnlyList<string> _field1 { get; private set; }
        internal IReadOnlyList<string> _field2 { get; private set; }
        internal IReadOnlyList<string> _field3 { get; private set; }
        internal IReadOnlyList<string> _field4 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field5 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field6 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<IReadOnlyList<int>>> _field7 { get; private set; }
        internal IReadOnlyList<string> _field8 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field9 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field10 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field11 { get; private set; }
        internal _TbCommonItem(ByteBuf _buf)
        {
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field0 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field1 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field2 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field3 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field4 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field5 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field6 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][][]; _field7 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[][] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1][]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int[] __v1; { int __n2 = _buf.ReadSize(); var __f2 = new int[__n2]; __v1 = __f2; for (var __i2 = 0 ; __i2 < __n2 ; __i2++ ){ int __v2; __v2 = _buf.ReadInt(); __f2[__i2] = __v2;} } __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new string[__n0]; _field8 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ string __v0; __v0 = _buf.ReadString(); __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field9 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field10 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field11 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
        }

    }
}
